Skip to content

fix(tcp): return one line per passive receive - #102

Merged
mremond merged 1 commit into
mainfrom
infinitary-batch/0f06f818
Dec 1, 2026
Merged

mremond merged 1 commit into
mainfrom
infinitary-batch/0f06f818

Conversation

@mremond

@mremond mremond commented Dec 1, 2026

Copy link
Copy Markdown
Member

Why

When an Erlang program asked for the next line from a TCP connection, Nera could hand it several separate commands as one.

What changed

  • A program asking for the next line receives just one line, including its line ending.
  • An unfinished line stays available after a timeout.
  • Closing the connection tells a waiting program that the connection closed.
  • Lines longer than 300,000 bytes return an error. A program can still recover the original bytes by turning off line processing.

Before and after

Before: One read returned all 14 bytes of three queued lines together.

After: Three reads return 8, 5 and 1 bytes separately, keeping both line endings and the empty line.

This changes what a program receives, not a screen; the socket transcripts show the returned values.

Checked

Live validation: Demonstrated for this version. 3 of 3 scenarios driven live in the product.

Scenario Result Evidence
Read three queued TCP lines separately ✅ Passed live The fixed Linux program matched both BEAM backends byte for byte; the original returned all three lines together.
Wait for a line or for the socket to close ✅ Passed live A measured timeout kept the partial line. Pending reads completed when data arrived or returned closed when the socket closed.
Read at the 300,000-byte limit and recover oversized data ✅ Passed live The boundary line arrived intact. An extra byte triggered an error, and raw mode recovered all 300,001 bytes.
  • Independent review of pending reads: Closing a socket wakes the reader, and canceling a read preserves its bytes. Neither changes successful reads.
  • Windows close review and target check: The blocking reader reports shutdown as closed without changing other errors. The Windows target type-check passed; native Windows execution was not tested.
  • Linux Rust and native suites: Clippy passed; 2,303 Rust tests and 554 native tests passed. One Rust test was ignored and two native tests need external modules.
  • Rust retained-byte regressions: Both tests rejected builds that dropped the guarded bytes and then passed ten consecutive runs.
How it was checked

Built the release runtime before the compiler. Ran strict workspace Clippy, the complete Rust workspace, and all three native end-to-end shards on Linux.

Ran each native fixture ten times with default schedulers and ten with one scheduler. The ordinary-line transcript matched both BEAM backends.

The change-map, allocator configuration, stacktrace order, and native test-storage checks passed. Cross-object checks produced Mach-O x86-64 and ELF AArch64 objects.

Risk

Risk above low: Blast radius, medium — TCP reads share the socket buffer and reactor close handling.; Evidence, medium — Linux is proven end to end; Windows close behavior is source-reviewed and type-checked.

Full risk assessment
Dimension Level Why
Blast radius medium TCP reads share the socket buffer and reactor close handling.
Behavior low Corrects line boundaries in an existing passive receive mode.
Undo low A revert restores the old behavior without moving persistent data.
Evidence medium Linux is proven end to end; Windows close behavior is source-reviewed and type-checked.
Sensitivity low Only local disposable TCP connections were needed for verification.
Novelty low The fix uses the existing receive loop, byte queue, and reactor.
Dependencies low No dependencies changed.
Not done

Approving adds this change to the next batch. The app merges the batch only if the project’s hosted checks pass.

Positive-length reads and partial lines buffered before leaving active mode are unchanged. Native Windows runtime behavior was not exercised.

A program asking for the next line receives just one line, including its line ending.

An unfinished line stays available after a timeout.

Closing the connection tells a waiting program that the connection closed.

Lines longer than 300,000 bytes return an error. A program can still recover the original bytes by turning off line processing.
@github-actions github-actions Bot added this to the 0.1.1 milestone Dec 1, 2026
@mremond
mremond merged commit 0921692 into main Dec 1, 2026
22 checks passed
@mremond
mremond deleted the infinitary-batch/0f06f818 branch December 1, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant